package com.fm.base.net.proxy;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

public class Proxy {
	public String host;
	public int port;
	public Set<ProxyProtocol> protocols = new HashSet<>();

	public Proxy(String host, int port) {
		this.host = host;
		this.port = port;
	}

	public Proxy(String host, int port, ProxyProtocol... protocols) {
		this.host = host;
		this.port = port;
		Collections.addAll(this.protocols, protocols);
	}

	@Override
	public String toString() {
		return host + ":" + port;
	}

	@Override
	public int hashCode() {
		return toString().hashCode();
	}

	@Override
	public boolean equals(Object object) {
		if (this == object) {
			return true;
		} else if (object instanceof Proxy) {
			return ((Proxy) object).host.equals(host) && ((Proxy) object).port == port;
		}
		return false;
	}
}
